var geocoder;
var list;
function initGeocoder(){
    geocoder = new google.maps.Geocoder();
}
                    
function geocodeAddr(adr) {
                    
    geocoder.geocode({
        address: adr
    }, function(responses) {
        $('#lat').val(0);
        $('#lng').val(0);
        if (responses)
            if(responses.length > 0){
                $('#lat').val(responses[0].geometry.location.lat());
                $('#lng').val(responses[0].geometry.location.lng());
                advs[_i-1].innerHTML=responses[0].geometry.location.lat() + " " + responses[0].geometry.location.lng();  
                $('#updateLocation').trigger('click');
            }
    });
}
var advs,_i;
function geocode(){
    initGeocoder();
    advs=$('#advs tr td');
    _i=0;
    timeGeoCoding();
}
function timeGeoCoding() {
    setTimeout("procGeoCoding()",1000);
}
function procGeoCoding() {
        $('#id').val(advs[_i].innerText);
        $('#adr').val(advs[_i+1].innerText);
        geocodeAddr(advs[_i+1].innerText);
        _i+=3;
        if(_i<advs.length){
            timeGeoCoding();
        }
    }
        